<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ page import="java.sql.*" %>
<html> 
<head>
</head>
<body>
<%
            String w1=request.getParameter("user");
	    String w2=request.getParameter("password");
	    int i=1;
         
	    if((w1==null||w1.equals(""))||(w2==null||w2.equals("")))
	     {
	    	i=0;
	    	 %> <script type="text/javascript">
	            alert("信息不全，请重新输入",window.location.href="denglu.jsp");
	            </script>
	          <%
	     }
	     else
	     {
%>
	<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
							//载入驱动程序类别
	String url="jdbc:odbc:shujuku01";
		String user="";
		String pwd="";
							//建立数据库链接，stuDataBase为ODBC数据源名称
Connection con=DriverManager.getConnection(url,user,pwd);
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
							//建立ResultSet(结果集)对象,并执行sql语句
	ResultSet rs=stmt.executeQuery("select * from user");
		rs.last();
	%>
	
	<%
	    
		rs.beforeFirst();     //移至第一条记录之前
								//利用while循环配合next方法将数据表中的记录列出
		while(rs.next())
		{
		 String q1=rs.getString("user");
	     String q2=rs.getString("password");
	     
		 if( w1.equals(q1)==true )
		    {
			 i=0;
			 if( w2.equals(q2)==true )
			    {
				 session.setAttribute("yonghuming",w1);
				 %> <script type="text/javascript">
		            alert("成功",window.location.href="zhuye.jsp");
		            </script>
		          <%
				    
			    }
			 else
			 {
				 %> <script type="text/javascript">
		            alert("信息错误，请重新输入",window.location.href="denglu.jsp");
		            </script>
		          <%
			 }
		    }
		 
	     }
		}
	if(i==1)
	{
		%> <script type="text/javascript">
        alert("您未注册,请您注册",window.location.href="denglu.jsp");
        </script>
      <%
	}
		%>
</body>
</html>